home *** CD-ROM | disk | FTP | other *** search
JavaScript | 2001-02-20 | 5.2 KB | 230 lines | [AMAS/AMAP] |
- /**
- * 3SpaceInstaller.js
- *
- *
- * Created: Mon Oct 16 19:50:45 2000
- *
- * @author Mickael Gasrel
- * @version 1.0
- */
-
- /*
- * Global variables
- */
- var winNetPluginVersion = "3.1.0.4" ;
- var winExpPluginVersion = 0000 ;
- var macNetPluginVersion = 0000 ;
-
- var jarDirWin = "http://lion.g5g.fr/mickael/3SpaceWin.jar" ;
- //var jarDirWin = "http://3SpaceWin.jar" ;
- var jarDirMac = "../3SpaceMac.jar" ;
- var cabDirWin ="" ;
-
- /*
- * You must call the function findBrowser () to initialize this four variables.
- */
- var platformName ;
- var browserName ;
- var numberVersion ;
- var pluginVersion = -1 ;
-
- /*
- * Used to find informations on the browser. The informations are :
- * - name of the platform,
- * - name of the browser,
- * - number of the version of the navogator.
- * The function return Unknown if the plugin can't be supported.
- */
- function findBrowser () {
- platformName = findPlatformName () ;
- browserName = findBrowserName () ;
- numberVersion = findNumberVersionBrowser () ;
- var browser = "Unknown" ;
-
- if (platformName == "Unknown" || browserName == "Unknown" || numberVersion == "NaN") {
- return browser ;
- }
-
- if (browserName == "Netscape") {
- if (platformName == "Windows") {
- if (numberVersion >= 4) {
- browser = "Net.Win.4" ;
- pluginVersion = winNetPluginVersion ;
- }
- }
- else {
- if (platformName == "Macintosh") {
- if (numberVerion >= 4) {
- browser = "Net.Mac.4" ;
- pluginVersion = macNetPluginVersion ;
- }
- }
- }
- }
-
- else {
- if (browserName == "Explorer") {
- if (platformName == "Windows") {
- if (numberVersion >= 4) {
- browser = "Exp.Win.4" ;
- pluginVersion = winExpPluginVersion ;
- }
- }
- }
- }
-
- return browser ;
- }
-
- /*
- * Used to know if a user has a plugin or the last version of this plugin.
- * The function return false if there is nothing to do and true if
- * the plugin must be replaced.
- * The function findBrowser () must be call before this function.
- */
- function installNewPlugin (mimeType, pluginName) {
- if (pluginVersion == -1) {
- return false ;
- }
-
- if (findPlugin (mimeType, pluginName) == false) {
- return true ;
- }
-
- var pluginDescription = navigator.plugins [pluginName].description ;
- var indexVersion = pluginDescription.indexOf ("version") ;
-
- if (indexVersion == -1 || indexVersion == "") {
- return false ;
- }
-
- //var userVersion = parseFloat (pluginDescription.substring (indexVersion + 8, indexVersion + 14)) ;
- var userVersion = pluginDescription.substring (indexVersion + 8, indexVersion + 16) ;
-
- if (userVersion < pluginVersion) {
- return true ;
- }
- else {
- return false ;
- }
- }
-
- /*
- * Used to update or installe the plugin.
- */
- function updatePlugin () {
- var browser = findBrowser () ;
- var install = installNewPlugin ("application/x-z3d","3Space Plugin") ;
-
- if (install == true) {
- if (browser == "Net.Win.4") {
- netscape.softupdate.Trigger.StartSoftwareUpdate (jarDirWin, netscape.softupdate.Trigger.DEFAULT_MODE) ;
- }
- else if (browser == "Net.Mac.4") {
- netscape.softupdate.Trigger.StartSoftwareUpdate (jarDirMac, netscape.softupdate.Trigger.DEFAULT_MODE) ;
- }
- }
- }
-
- /*
- * Used to find the name of the platform.
- * The function can return :
- * - Windows,
- * - Macintosh,
- * - Unknown.
- * Example for the field navigator.userAgent :
- * Mozilla/2.0 (Win16; I).
- */
- function findPlatformName () {
- var platform = navigator.userAgent ;
- var indexWin = (platform.toLowerCase ()).indexOf ("win") ;
- var indexMac = (platform.toLowerCase ()).indexOf ("mac") ;
-
- if (indexWin != -1 && indexWin != "") {
- platformName = "Windows" ;
- }
- else {
- if (indexMac != -1 && indexMac != "") {
- platformName = "Macintosh" ;
- }
- else {
- platformName = "Unknown" ;
- }
- }
-
- return platformName ;
- }
-
- /*
- * Used to find the name of the browser.
- * The function can return :
- * - Netscape,
- * - Explorer,
- * - Unknown.
- * Example for the field navigator.appName :
- * Netscape
- */
- function findBrowserName () {
- var browser = navigator.appName.toLowerCase () ;
-
- if (browser == "netscape") {
- browserName = "Netscape" ;
- }
- else {
- if (browser == "microsoft internet explorer") {
- browserName = "Explorer" ;
- }
- else {
- browserName = "Unknown" ;
- }
- }
-
- return browserName ;
- }
-
- /*
- * Used to find the number of the version of the navigator.
- * if there is a problem the function return NaN (Not a Number).
- * Example for the field navigator.appVersion :
- * 3.0 (WinNT, I)
- */
- function findNumberVersionBrowser () {
- var version = navigator.appVersion ;
- numberVersion = parseFloat (version.substring (0, version.indexOf (" "))) ;
- return numberVersion ;
- }
-
- /*
- * Used to know if the plugin is installed.
- * Example for the parameters :
- * - mimeType: application/x-zap
- * - pluginName: TGS Europe NPZap
- */
- function findPlugin (mimeType, pluginName) {
- var sizePlugin = navigator.plugins.length ;
-
- for (var i = 0 ; i < sizePlugin ; i++) {
- var aPlugin = navigator.plugins[i] ;
- if (aPlugin.name == pluginName) {
- var sizeMime = aPlugin.length ;
- for (var j = 0 ; j < sizeMime ; j++) {
- var aMime = aPlugin [j] ;
- if (aMime.type == mimeType) {
- return true ;
- }
- }
- }
- }
- return false ;
- }
-
-
-
-
-
-
-
-
-
-
-